<!--引入init配置文件-->
<?php
    require "init.php";
    //接收传过来的商品名称关键字
    $key_name = $_POST['key_name'];

    $sql = "
        select
        i.iname,g.gname,g.price,g.msg,g.id,g.cate_id,c.cname
        from
        ".PRE."goods as g,".PRE."image as i,".PRE."category as c
        where
        g.id = i.goods_id and c.id = g.cate_id and i.cover = 1 and g.state = 1 and g.gname like '%$key_name%' order
         by cate_id

    ";

    $goods_list = query($link, $sql);


?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <link rel="icon" href="./public/home/imgs/logo.jpg">
    <title>小米手机专卖店(ximiao)</title>

    <!-- Bootstrap -->
    <link href="./public/home/css/bootstrap.min.css" rel="stylesheet">
    <link href="./public/home/css/index.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="./public/home/js/html5shiv.min.js"></script>
    <script src="./public/home/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <!--引入导航条-->
    <?php require ROOT_PATH."./com/nav.php" ?>

    <div class="container mt50">
        <div class="row mt20">
            <?php if(empty($goods_list)):?>
                <h3 class="text-center text-danger">暂无数据</h3>
            <?php else:?>
                <?php $temp = 0;?>
                <?php foreach ( $goods_list as $item):?>
                    <?php
                        $new_temp = $item['cate_id'];
                        if($temp != $new_temp){
                            $temp = $new_temp;
                            echo "<div class='row mt20'>&nbsp;</div><h2 class='text-info text-center'><b>".$item['cname']."</b></h2>";
                        }
                    ?>
                    <div class="col-sm-6 col-md-3">
                        <div class="thumbnail">
                            <!-- 商品图片-->
                            <a href="./goods_details.php?id=<?php echo $item['id']?>">
                                <img src="<?php echo get_img_url(ROOT_URL . './upload',$item['iname'],350)?>">
                            </a>
                            <div class="caption">
                                <!-- 商品名字-->
                                <a href="./goods_details.php?id=<?php echo $item['id']?>">
                                    <h3><?php echo $item['gname']?></h3>
                                </a>
                                <!-- 商品介绍-->
                                <p style="overflow: hidden;height: 60px"><?php echo $item['msg'];?></p>
                                <!-- 商品价格-->
                                <h3>
                                    <span class="glyphicon glyphicon-jpy"></span>
                                    <?php echo $item['price']?>

                                    <a href="./com/buydo.php?act=zan&goods_id=<?php echo $item['id']?>" class="pull-right text-danger">
                                        <span class="glyphicon glyphicon-heart"></span>
                                    </a>


                                </h3>
                            </div>
                        </div>
                    </div>
                <?php endforeach;?>
            <?php endif;?>

        </div>
    </div>

    <!--引入底部开始-->
    <?php require ROOT_PATH."./com/footer.php" ?>


<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="./public/home/js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="./public/home/js/bootstrap.min.js"></script>
</body>
</html>

